package com.jservice.web.supplier;

import com.jservice.framework.annotation.RouteBind;
import com.jservice.framework.dto.Message;
import com.jservice.model.SysUser;
import com.jservice.web.WebConstant;
import com.jservice.web.base.JBaseController;
import com.jservice.web.sysUser.SysUserService;

/**
 * SupplierController
 *
 * @Author cwledit
 * @DATE 2017/7/13.
 */
@RouteBind(path = "/admin/supplier")
public class SupplierController extends JBaseController{

    public void edit(){
        SysUser cUser = getCUser();
        setAttr("admin",cUser);
        render("edit");
    }

    public void update(){
        SysUser cUser = getModel(SysUser.class,"sysUser");
        if (SupplierService.me().update(cUser)){
            SysUser sysUser = SysUserService.DAO.findById(cUser.getId());
            setSessionAttr(WebConstant.request_cUser,sysUser);
            setFlashMessage(Message.success("用户更新成功"));
        }else{
            setFlashMessage(Message.error("用户更新失败"));
        }
        redirect("/admin/index");
    }

}
